package com.kx.smsplantform.config;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Sun
 * @Date 2021/7/7 17:38
 */
@Configuration
public class JobConfig {

    /**
     * jobName:定时任务名
     * shardingTotalCount:分片数
     * cron:定时任务表达式
     */


    /**
     *监控sms_send_gateway_?，如果消息堆积，达到一定数量，需要给运维人员发送邮件。
     */
    @Bean
    public JobConfiguration monitorRabbitConfiguration(){
        JobConfiguration monitorRabbit = JobConfiguration.newBuilder("monitorRabbit", 1).cron("0/10 * * * * ?").build();
        return monitorRabbit;
    }

    /**
     *定时监控所有客户的余额，如果剩余金额少于1000大洋，发送短信给客户
     */
    @Bean
    public JobConfiguration monitorBalanceConfiguration(){
        JobConfiguration monitorBalance = JobConfiguration.newBuilder("monitorBalance", 1).cron("0 0 0/1 * * ? ").build();
        return monitorBalance;
    }
}
